package com.google.code.teamtools.client.view;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.google.code.teamtools.client.AppEvents;

public class TaskFolderView extends View
{
    private ContentPanel tasks;

    public TaskFolderView(Controller controller)
    {
        super(controller);
    }

    @Override
    protected void handleEvent(AppEvent event)
    {
        if (event.getType() == AppEvents.Init) {
            initUI();
        }
    }

    @Override
    protected void initialize()
    {
    }

    protected void initUI()
    {
        tasks = new ContentPanel();
        tasks.setAnimCollapse(false);
        tasks.setHeading("Tasks");
        tasks.addListener(Events.Expand, new Listener<ComponentEvent>()
        {

            public void handleEvent(ComponentEvent be)
            {
                Dispatcher.get().dispatch(AppEvents.NavTasks);
            }
        });

        ContentPanel west = (ContentPanel) Registry.get(AppView.WEST_PANEL);
        west.add(tasks);
    }
}
